package rank1400;

import java.util.Arrays;

/**
 * 1886. 判断矩阵经轮转后是否一致
 */
public class No1886 {
    public boolean findRotation(int[][] mat, int[][] target) {
        if (Arrays.deepToString(mat).equals(Arrays.deepToString(target))) return true;
        for (int i = 0; i < 3; i++) {
            rotate(mat);
            System.out.println(Arrays.deepToString(mat));
            if (Arrays.deepToString(mat).equals(Arrays.deepToString(target))) return true;
        }
        return false;
    }

    private void rotate(int[][] mat) {
        int n = mat.length;
        for (int i = 0; i < (n + 1) / 2; i++) {
            for (int j = 0; j < n / 2; j++) {
                int temp = mat[i][j];
                mat[i][j] = mat[n - 1 - j][i];
                mat[n - 1 - j][i] = mat[n - 1 - i][n - 1 - j];
                mat[n - 1 - i][n - 1 - j] = mat[j][n - 1 - i];
                mat[j][n - 1 - i] = temp;
            }
        }
    }
}
